// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'

import 'swiper/dist/css/swiper.css'; //滑动样式
import './assets/font/iconfont.css'
import 'mint-ui/lib/style.css';
import { $API } from '@/services/api'

Vue.prototype.$API = $API


import axios from 'axios'; //引入接口插件同时挂在接口
Vue.prototype.$http = axios;

// import '@/assets/css/common.scss'

router.beforeEach((to, from, next) => {
  if (to.meta.auth) { //判断该路由是否需要登录权限
    // 对路由进行验证
    if (localStorage.getItem('authorization')) { // 已经登陆
      next()
    } else {
      // 未登录,跳转到登陆页面，并且带上 将要去的地址，方便登陆后跳转。
      //next({path:'/login',query:{ referrer: to.fullPath} })
      router.push({
        name: '/login'
      });
    }
  } else {
    next()
  }
})


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
